home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-11-13 | 2.4 KB | 120 lines | [TEXT/nX^n] |
- void ExtToDouble( ext, dbl )
- extended *ext;
- double *dbl;
- /******************************
- * given the extended IEEE number
- * passed in, return its double
- * representation
- *
- ******************************/
- {
-
- asm{
- move.l 8(A6),-(sp) ; address of the extended
- move.l 12(A6),-(sp) ; address of the double
- move.w #FX2D,-(sp) ; push the appropriate opword
- _FP68K
- }
- }
-
- void DoubleToExt( dbl, ext )
- double *dbl;
- extended *ext;
- /******************************
- * given the double number
- * passed in, return its extended
- * representation
- *
- ******************************/
- {
-
- asm{
- move.l 8(A6),-(sp) ; address of the double
- move.l 12(A6),-(sp) ; address of the extended
- move.w #FD2X,-(sp) ; push the appropriate opword
- _FP68K
- }
- }
-
- void LongToExt( lg, ext )
- long *lg;
- extended *ext;
- /******************************
- * given the long number
- * passed in, return its extended
- * representation
- *
- ******************************/
- {
-
- asm{
- move.l 8(A6),-(sp) ; address of the long
- move.l 12(A6),-(sp) ; address of the extended
- move.w #FL2X,-(sp) ; push the appropriate opword
- _FP68K
- }
- }
-
- void ExtToLong( ext, theint )
- extended *ext;
- long *theint;
- /******************************
- * given the extended IEEE number
- * passed in, return its long word
- * representation
- *
- ******************************/
- {
- asm{
- move.l 8(A6),-(sp) ; pointer to the extended
- move.l 12(A6),-(sp) ; address of the long
- move.w #FX2L,-(sp) ; push the appropriate opword
- _FP68K
- }
- }
-
- void DoubleToLong( dbl, theint )
- double *dbl;
- long *theint;
- /******************************
- * A simple conversion utility that might be useful
- * for debugging at the TMON and MACSBUG level.
- ******************************/
- {
- extended temp;
-
- DoubleToExt( dbl, &temp);
- ExtToLong( &temp, theint );
- }
-
- void ExtendedToStr( ext, theStr )
- extended *ext;
- char *theStr;
- /*******************************
- * convert an extended to a string
- *
- * First convert the number to
- * a decimal record and then convert
- * the decimal record to a string.
- *
- * The Hypercard callback "ExtToStr" does
- * this for you. I've added it here for those
- * cases where you can't make a callback
- *
- * The conversions uses the decimal record
- * structure that's documented in Apple Numerics
- * manual.
- *******************************/
- {
- decform decrec;
- decimal decnum;
-
- /*** convert the extended to a decimal ***/
-
- decrec.style = FIXEDDECIMAL;
- decrec.digits= 0;
- num2str( &decrec, *ext, theStr );
- }
-
- LISTING 1. Some Interesting SANE conversion utilities
-